<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>慢图浏览</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="description" content="Description">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="static/css/vue.css">
    <script src="static/js/docsify-edit-on-github.js"></script>
    <link href="static/css/lightbox.min.css" rel="stylesheet"/>
</head>
<body>
<nav>
    <a href="/#/download">获取下载地址</a>
</nav>
<div id="app"></div>
<script>
    window.$docsify = {
        homepage: "readme.md",
        name: '',
        loadSidebar: true,
        repo: "https://github.com/RelaxPic/relaxpic.github.io",
        relativePath: true,
        // 初始化Fancybox
        afterRender: function () {
            $('[data-fancybox]').fancybox();
        },
        plugins: [
            EditOnGithubPlugin.create("https://github.com/RelaxPic/relaxpic.github.io/blob/master/", null, function (file) {
                if (file.indexOf('en') === -1) {
                    return '编辑此页面'
                } else {
                    return 'edit on git'
                }
            }),
            function pageFooter(hook, vm) {
            },
        ],
    }
    if (typeof navigator.serviceWorker !== 'undefined') {
        if (!location.host.startsWith("localhost")) {
            navigator.serviceWorker.register('sw.js')
        }
    }

</script>
<script>
    console.log("开始校验")
    let ts = localStorage.getItem("lastTimestamp");
    let needFresh = false;
    if(!ts){
        ts = Date.now();
        localStorage.setItem("lastTimestamp", ts);
        needFresh = true;
    }
    function refresh() {
        const ts = Date.now();
        fetch("/version?v=" + ts).then(res => res.text()).then(version => {
                localStorage.setItem("lastTimestamp", ts);
                const versionInCache = localStorage.getItem("version");
                if (versionInCache !== version) {
                    localStorage.setItem("version", version)
                    console.log("远程版本版本: " + version + ",本地版本:" + versionInCache + ",更新了")
                    window.location.reload();
                } else {
                    console.log("远程版本版本: " + version + ",本地版本:" + versionInCache + "不需要更新")
                }
            }
        )
    }
    if(needFresh){
        console.log("没有数据,需要强制刷新")
        refresh();
    }else  if(Date.now() - parseInt(ts) > 1000 * 3600){
        console.log("超过时间范围,需要更新数据")
        refresh();
    }
</script>
<!-- Docsify v4 -->
<script src="static/js/docsify.min.js"></script>
<script src="static/js/lightbox-plus-jquery.min.js"></script>
</body>
</html>
